package pl.mcnova.model.combo;

import java.util.ArrayList;
import java.util.List;

import pl.mcnova.model.dao.DeviceDAO;
import pl.mcnova.model.entity.Device;

public class DeviceModelComboBoxModel extends ComboModel {

	private DeviceDAO deviceDAO;

	public DeviceModelComboBoxModel() {
		deviceDAO = new DeviceDAO();
		data = deviceDAO.getAllGroupedByNumbers("model");
		selectedItem = null;
	}

	public DeviceModelComboBoxModel(List<Device> Devices) {
		deviceDAO = new DeviceDAO();

		if (Devices != null) {
			data = Devices;
			selectedItem = Devices.get(0);
		} else {
			data = new ArrayList<Device>();
			selectedItem = null;
		}
	}

	public void refresh() {
		data = deviceDAO.getAllGroupedByNumbers("model");
	}

}